package com.imooc.form;

import com.imooc.form.group.Insert;
import com.imooc.form.group.Update;
import lombok.Data;

import javax.persistence.Id;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * FileName: ProductForm.java
 * Description: TODO
 *
 * @author HuangRI(874668739 @ qq.com)
 * @version 1.0
 * @date 2020/12/31
 */
@Data
public class ProductForm {
    /**
     * 商品ID
     */
    @Id
    @NotEmpty(message = "商品ID不能为空", groups = {Update.class})
    private String productId;

    /**
     * 商品名称
     */
    @NotEmpty(message = "商品名称不能为空", groups = {Insert.class, Update.class})
    private String productName;

    /**
     * 单价
     */
    @NotEmpty(message = "单价不能为空", groups = {Insert.class, Update.class})
    @Min(value = 0, message = "商品价格不正确")
    private BigDecimal productPrice;

    /**
     * 库存
     */
    @NotNull(message = "库存不能为空", groups = {Insert.class, Update.class})
    @Min(value = 0, message = "库存数量有误")
    private Integer productStock;

    /**
     * 描述
     */
    @NotEmpty(message = "描述不能为空", groups = {Insert.class, Update.class})
    private String productDescription;

    /**
     * 小图，链接地址
     */
    @NotEmpty(message = "图片地址不能为空", groups = {Insert.class, Update.class})
    private String productIcon;

    /**
     * 类目编号
     */
    @NotNull(message = "类目编号不能为空", groups = {Insert.class, Update.class})
    private Integer categoryType;
}
